package org.git.movie.videojiexi.service.impl;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class TestImpl {
    public static void main1(String[] args) throws IOException {
        String url = "https://v.html5.qq.com/node/h5videoPlayer?vid=5984091005311059307";

        String htmls = Jsoup.connect(url).ignoreContentType(true).execute().body();
        System.out.println(htmls);

        List<Object> list  = new ArrayList<Object>();
        //
        Document doc = null;
        try {
            doc = Jsoup.connect(url).get();
        } catch (Exception e) {
            ///e.printStackTrace();
            System.out.println(e.getMessage()+":--------------->"+url);
        }
        if( doc == null )return ;
        Elements elScripts = doc.getElementsByTag("script");
        String vcontent = null;
        for(Element scriptItem :elScripts){
           String content =  scriptItem.data().toString();
           if(content != null && content.indexOf(" window.pageData") >= 0){
               vcontent = content.trim();
               break;
           }
        }
        System.out.println(vcontent==null?"null":vcontent);

    }

    public static void main(String[] args) throws IOException {
        String url = "https://wapv.sogou.com/sgsearch/sgs_video.php?docId=sf_403107906255650816&mat=12";
        String htmls = Jsoup.connect(url).ignoreContentType(true).execute().body();
        System.out.println(htmls);
    }
}
